﻿Public Class SALON_DE_RECEPCIONES
    Dim rs As ADODB.Recordset
    Dim sql As String
    Dim valor_extra As Double = 0
    Dim valor As Double = 0
    Dim codi_recepcion As String = ""
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        sql = "SELECT DESCRIPCION, [COSTO EXTRA] FROM [TIPO EVENTO] WHERE (DESCRIPCION = '" & ComboBox1.SelectedItem.ToString & "')"
        rs = coneccion.Execute(sql)
        valor_extra = rs.Fields(1).Value
    End Sub

    Private Sub SALON_DE_RECEPCIONES_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DoubleClick
        llenar(Resultado)
    End Sub

    Private Sub SALON_DE_RECEPCIONES_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        conectar()
        sql = "SELECT DESCRIPCION FROM [TIPO EVENTO]"
        rs = coneccion.Execute(sql)
        While rs.EOF <> True
            If rs.EOF = True Then
                Exit While
            End If
            ComboBox1.Items.Add(rs.Fields(0).Value)
            rs.MoveNext()
        End While
        TextBox1.Text = ""
    End Sub

    Private Sub btnVerificar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVerificar.Click
        Dim mostrar As New Resultados(txtPaterno.Text, txtMaterno.Text, txtNombre.Text, txtCodigo.Text)
        mostrar.Show()
    End Sub
    Public Sub llenar(ByVal Resultado As String)
        sql = "SELECT CODI_CLIEN, NOMB_CLIEN, PATE_CLIEN, MATE_CLIEN  FROM CLIENTE WHERE (CODI_CLIEN = '" & Resultado & "')"
        rs = coneccion.Execute(sql)
        txtNombre.Text = rs.Fields(1).Value
        txtPaterno.Text = rs.Fields(2).Value
        txtMaterno.Text = rs.Fields(3).Value
        txtCodigo.Text = rs.Fields(0).Value
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        sql = "SELECT CODI_RECEPCION, COSTO, CONCEPTO FROM(Recepcion) WHERE (CONCEPTO = '" & RadioButton1.Text & "')"
        rs = coneccion.Execute(sql)
        valor = rs.Fields(1).Value
        codi_recepcion = rs.Fields(0).Value
    End Sub

    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        sql = "SELECT CODI_RECEPCION, COSTO, CONCEPTO FROM(Recepcion) WHERE (CONCEPTO = '" & RadioButton3.Text & "')"
        rs = coneccion.Execute(sql)
        valor = rs.Fields(1).Value
        codi_recepcion = rs.Fields(0).Value
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        sql = "SELECT CODI_RECEPCION, COSTO, CONCEPTO FROM(Recepcion) WHERE (CONCEPTO = '" & RadioButton2.Text & "')"
        rs = coneccion.Execute(sql)
        valor = rs.Fields(1).Value
        codi_recepcion = rs.Fields(0).Value
    End Sub

    Private Sub SALON_DE_RECEPCIONES_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        txtPago.Text = valor + valor_extra
        txtIgv.Text = CDbl(txtPago.Text) * 0.19
        txtTotal.Text = CDbl(txtPago.Text) * 1.19
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim cancelado As String
        If ComboBox2.SelectedItem <> "" Then
            cancelado = "SI"
        Else
            cancelado = "NO"
        End If
        Try
            sql = "INSERT INTO [REGISTRO RECEPCION](CODI_CLIEN, FECHA_PEDIDO, FECHA_RECEPCION, CODI_RECEPCION, CANCELADO) VALUES ('" & txtCodigo.Text & "','" & Entrega.Value.ToString & "','" & Ahora.Value.ToString & "','" & codi_recepcion & "','" & cancelado & "')"
            rs = coneccion.Execute(sql)
            Dispose()
        Catch ex As Exception
            MsgBox("Ya fue registrado seleccione otro", MsgBoxStyle.Exclamation, "Error")
        End Try
    End Sub
End Class